"""
Case Type   : 基础功能-SQL语法-trigger
Case Name   : 执行\h drop event trigger
Create At   : 2024/10/21
Owner       : peilinqian
Description :
    step1: 执行\h drop event trigger
    step2: 执行\help drop event trigger
Expect      :
    step1: 执行\h drop event trigger  ; expect:成功
    step2: 执行\help drop event trigger  ; expect:成功
History     :
"""
import os
import unittest

from testcase.utils.CommonSH import CommonSH
from testcase.utils.Logger import Logger
from yat.test import Node


class ListPartitionCase(unittest.TestCase):
    def setUp(self):
        self.log = Logger()
        self.log.info(f'----{os.path.basename(__file__)}:初始化----')
        self.pri_dbuser = Node(node='PrimaryDbUser')
        self.pri_sh = CommonSH('PrimaryDbUser')
        self.check_msg = "Command:?.*DROP EVENT TRIGGER\n" \
                         "Description: remove an event trigger\n" \
                         "Syntax:\n" \
                         "DROP EVENT TRIGGER \[ IF EXISTS \] name " \
                         "\[ CASCADE | RESTRICT \]"

    def test_main(self):
        step_txt = '----step1:执行\h drop event trigger; expect:成功----'
        self.log.info(step_txt)
        sql = f"\h drop event trigger; "
        result = self.pri_sh.execut_db_sql(sql)
        self.log.info(result)
        self.assertRegex(result, self.check_msg, '执行失败:' + step_txt)

        step_txt = '----step2:执行\help drop event trigger; expect:成功----'
        self.log.info(step_txt)
        sql = f"\help drop event trigger; "
        result = self.pri_sh.execut_db_sql(sql)
        self.log.info(result)
        self.assertRegex(result, self.check_msg, '执行失败:' + step_txt)

    def tearDown(self):
        self.log.info('----this is tearDown----')
        self.log.info(f'----{os.path.basename(__file__)}:执行完毕----')
